package com.example.lenovo.demo.presenter.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import java.util.List;

/**
 * Created by Lenovo on 2017/1/9.
 */

public class City_Header_VpAdapter extends PagerAdapter {
    private List<LinearLayout> data;
    private Context context;

    public City_Header_VpAdapter(List<LinearLayout> data,Context context) {
        super();
        this.data=data;
        this.context=context;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(data.get(position));
        return data.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
   //     super.destroyItem(container, position, object);
        container.removeView(data.get(position));
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view==object;
    }
}
